#include "NSSplitView.h"
#include "NSKeyedUnarchiver.h"

IMPLEMENT_DYNAMIC_CLASS(NSSplitView, NSView)

NSSplitView::NSSplitView() : NSView(), _isVertical(false), _split(NULL)
{
}

void NSSplitView::initWithUnarchiver(NSKeyedUnarchiver *archiver)
{
	NSView::initWithUnarchiver(archiver);

	if (archiver->contains(wxT("NSIsVertical")))
		_isVertical = archiver->decodeBoolForKey(wxT("NSIsVertical"));
}

void NSSplitView::_releaseWidget(void)
{
	if (_split)
	{
		_split->Destroy();
		_split = NULL;
	}
}

wxWindow* NSSplitView::_allocWidget(NSView *parent)
{
	wxWindow* pwidget = parent->widget();
	if (pwidget)
	{
		_split = new wxSplitterWindow(pwidget, -1, wxDefaultPosition, wxDefaultSize, wxSP_3D);
		wxASSERT(_split);
		/* SPLIT VERTICALLY / SPLIT HORIZONTALLY */
		_initWidget(_split);
	}
	return _split;
}
